package com.googlecode.latvian_ebooks.glossary;

import java.util.ArrayList;
import java.util.{ List => JavaList }

import scala.reflect.BeanProperty

class FullTerm(@BeanProperty var term: String,
  @BeanProperty var locString: String,
  @BeanProperty var translation: String) {

  @BeanProperty
  var locations = locString.replaceAll(" ", "").split(",").map(location => new Location(location)).toList

  @BeanProperty
  var correctTerm: String = null

  @BeanProperty
  var otherLocations: List[Location] = List.empty[Location]

  @BeanProperty
  var notes: String = null

  def pickTerm(): String = {
    if (correctTerm != null && correctTerm.trim().length() > 0 && !correctTerm.startsWith("(")) {
      return correctTerm;
    }
    return term;

  }

  override def toString(): String = {
    return "[" + pickTerm() + "]";
  }

}
